<?php

App::uses('AppModel', 'Model');
class File extends AppModel{
    public $validate = array(
        'contact_file' => array(
            'rule' => 'checkFilesExtension',
        ),
        'ids_file' => array(
            'rule' => 'checkFilesExtension',
        )
    );
    
    public function checkFilesExtension($data){
        $data  = array_shift($data);
        //pr($data);
        $errorFree = true;
        foreach($data as $fileDetails){
            if($fileDetails['name']){
                $pathInfo = pathinfo ( $fileDetails['name'] );
                if($pathInfo['extension'] != 'pdf'){
                    $errorFree = false;
                    break;
                }
            }
        }
        return $errorFree;
    }
}